﻿using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Collections;
using System.Linq;
using System.Windows.Forms;

namespace iTunesAutomator
{
    /*
     * Used for dealing with the file system.
     */
    class FileManager
    {
        public FileManager() { }

        public string RootPath { get; set; }

        public IEnumerable<string> GetDirectories()
        {
            return Directory.EnumerateDirectories(RootPath, "*");
        }

        public IEnumerable<string> GetDirectories(string path)
        {
            return Directory.EnumerateDirectories(path, "*");
        }

        public string GetDirectoryName(string path)
        {
            return path.Split('\\')[path.Split('\\').Length - 1];
        }

        public static string GetLastFilePath()
        {
            var path = Application.StartupPath + "\\filepath.txt";
            if (File.Exists(path))
            {
                return File.ReadAllLines(path)[0];
            }
            else
            {
                return String.Empty;
            }
        }

        public static void WriteLastFilePath(string filepath)
        {
            var path = Application.StartupPath + "\\filepath.txt";
            File.WriteAllText(path, filepath);
        }
    }
}
